(function ($) {
    'use strict';

    // [ JS Active Code Index ]

    // :: 1.0 Owl Carousel Active Code
    // :: 2.0 Slick Active Code
    // :: 3.0 Footer Reveal Active Code
    // :: 4.0 ScrollUp Active Code
    // :: 5.0 CounterUp Active Code
    // :: 6.0 onePageNav Active Code
    // :: 7.0 Magnific-popup Video Active Code
    // :: 8.0 Sticky Active Code
    // :: 9.0 Preloader Active code
    // :: 1.0 Owl Carousel Active Code


    $('#showModal').click(function () {
        $(this).css({ "display": "none" });
    });
    $('#subMes').click(function(e){
        e.preventDefault();
       
        var man_name=$('#username').val(),
            hall_descript=$('#desc').val(),
            mobile=$('#mobile').val();
        if(!man_name||!hall_descript||!mobile){
            alert('信息不全，请补全信息');
            return;
        }
        var data={
            man_name:man_name,
            hall_descript:hall_descript,
            mobile:mobile
        }
        $.ajax({
            url:'https://api.60huajia.com/mourn/hall/addhall_for_marketing',
            data:data,
            method:'post',
            success:function(res){
                if(res.code===1){
                    $.ajax({
                        url:'https://api.60huajia.com/mourn/wechatxinjidian/get_hall_qrcode?hall_id='+res.data.hall_id,
                        method:'get',
                        success:function(res){
                            if(res.code==1){
                                console.log(res.data.url);
                                $('.hall-img').attr('src', res.data.url);
                                $('.mobile').html(mobile);
                                $('.creat-hall').modal('hide');
                                $('.hall-name').html(man_name);
                                $('.hall-suc').modal('show');
                            }
                        }
                    })
                }else{
                    alert(res.message);
                }
            }
        })
    });
    var clipboard = new Clipboard('.copytext');
    clipboard.on('success', function(target){
        alert("复制成功！即将前往微信。");
        window.location.href = "weixin://";
    });

    var $window = $(window);
    if ($window.width() > 767) {
        new WOW().init();
    }

    $('.modal').on('show.bs.modal', function (e) {
        $(this).css('display', 'block');
        var modalHeight=$(window).height()/3 - $('.modal .modal-dialog').height();
        $(this).find('.modal-dialog').css({
            'margin-top': modalHeight
        });
    });

    $window.on('scroll', function () {
        if ($window.scrollTop() > 60) {
            $('.header_area').addClass('sticky slideInDown');
            $('.menu_area ').css('display','block');
        } else {
            $('.header_area').removeClass('sticky slideInDown');
            console.log();
            if($(window).width()<720){
                $('.menu_area ').css('display','none');
            }
        }
        if($window.scrollTop()>600&&$(window).width()<720){
            $('#bBtn').css('display','block');
        }else{
            $('#bBtn').css('display','none');
        }
    });
    $window.on('load', function () {
        $('#preloader').fadeOut('slow', function () {
            $(this).remove();
        });
    });

    if ($.fn.owlCarousel) {
        $(".welcome_slides").owlCarousel({
            items: 1,
            loop: true,
            autoplay: true,
            smartSpeed: 1500,
            nav: true,
            navText: ["<i class='pe-7s-angle-left'</i>", "<i class='pe-7s-angle-right'</i>"]
        });
        $(".app_screenshots_slides").owlCarousel({
            items: 2,
            loop: true,
            autoplay: true,
            smartSpeed: 800,
            margin: 30,
            center: true,
            dots: true,
            responsive: {
                0: {
                    items: 2
                },
                480: {
                    items: 3
                },
                992: {
                    items: 5
                }
            }
        });
    }

    if ($.fn.scrollUp) {
        $.scrollUp({
            scrollSpeed: 1500,
            scrollText: '<i class="fa fa-angle-up"></i>'
        });
    }
  
 
    // :: 2.0 Slick Active Code
    if ($.fn.slick) {
        $('.slider-for').slick({
            slidesToShow: 1,
            slidesToScroll: 1,
            speed: 500,
            arrows: false,
            fade: true,
            asNavFor: '.slider-nav'
        });

        $('.slider-nav').slick({
            slidesToShow: 3,
            slidesToScroll: 1,
            speed: 500,
            asNavFor: '.slider-for',
            dots: true,
            centerMode: true,
            focusOnSelect: true,
            slide: 'div',
            autoplay: true,
            centerPadding: '30px',
            mobileFirst: true,
            prevArrow: '<i class="fa fa-angle-left"></i>',
            nextArrow: '<i class="fa fa-angle-right"></i>'
        });
      
    }

    // :: 3.0 Footer Reveal Active Code
    if ($.fn.footerReveal) {
        $('footer').footerReveal({
            shadow: true,
            shadowOpacity: 0.3,
            zIndex: -101
        });
    }

    // :: 4.0 ScrollUp Active Code
   

    // :: 5.0 CounterUp Active Code
    if ($.fn.counterUp) {
        $('.counter').counterUp({
            delay: 10,
            time: 2000
        });
    }

    // :: 6.0 onePageNav Active Code
    if ($.fn.onePageNav) {
        $('#nav').onePageNav({
            currentClass: 'active',
            scrollSpeed: 2000,
            easing: 'easeOutQuad'
        });
    }

    // :: 7.0 Magnific-popup Video Active Code
    if ($.fn.magnificPopup) {
        $('.video_btn').magnificPopup({
            disableOn: 0,
            type: 'iframe',
            mainClass: 'mfp-fade',
            removalDelay: 160,
            preloader: true,
            fixedContentPos: false
        });
    }

    $('a[href="#"]').click(function ($) {
        $.preventDefault()
    });

})(jQuery);